//
//  SJAddColorCell.m
//  WSL
//
//  Created by CJ on 2017/10/16.
//  Copyright © 2017年 sanjuetech. All rights reserved.
//

#import "SJAddColorCell.h"
#import "SJAddItem.h"

@interface SJAddColorCell ()

@property (strong, nonatomic) UIImageView *colorImageView;

@end

@implementation SJAddColorCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView addSubview:self.colorImageView];
    self.colorImageView.sd_layout.spaceToSuperView(UIEdgeInsetsMake(0, 0, 0, 0));
    
}

- (void)setItem:(SJAddItem *)item {
    
    _item = item;
    
    if ([item.colorCode isEqualToString:@"1"]) { // 黄
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_yellow_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_yellow_sel"];
        }
    } else if ([item.colorCode isEqualToString:@"2"]) { // 蓝
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_blue_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_blue_sel"];
        }
    } else if ([item.colorCode isEqualToString:@"3"]) { // 绿
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_green_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_green_sel"];
        }
    } else if ([item.colorCode isEqualToString:@"4"]) { // 紫
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_purple_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_purple_sel"];
        }
    } else if ([item.colorCode isEqualToString:@"5"]) { // 红色
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_red_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_red_sel"];
        }
    } else if ([item.colorCode isEqualToString:@"6"]) { // 白色
        if ([item.state isEqualToString:@"1"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_white_nor"];
        } else if ([item.state isEqualToString:@"2"]) {
            self.colorImageView.image = [UIImage imageNamed:@"upload_btn_color_white_sel"];
        }
    }
}

#pragma mark - getter
- (UIImageView *)colorImageView{
    
    if (!_colorImageView) {
        
        _colorImageView = [UIImageView new];
        _colorImageView.contentMode = UIViewContentModeCenter;
        
    }
    return _colorImageView;
}

@end
